Brief Full Advanced Search Search Tips
|  |  | To access the contents, click the chapter and section titles. Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6! (Publisher: The Coriolis Group) Author(s): Peter G. Aitken ISBN: 1576102815 Publication Date: 08/01/98 Search this book:
Previous | Table of Contents | Next
## Chapter 7 Objects And Classes—Beyond The Basics You can do a lot more with classes in Visual Basic. Objects are such an important part of programming in Visual Basic that it is difficult to think of anything you can do without using them in one way or another. It goes without saying (although I am going to say it anyway) that the more you know about what objects are available in Visual Basic, and how to use them, the better you will be as a programmer. This chapter will show you how to work with some of the more useful objects that Visual Basic offers. ### The Collection Class One of the most useful classes provided in Visual Basic is the Collection class. Not only does Visual Basic use collections in many of the other classes it provides (for example, the ListView class will be covered later in this chapter), but it lets you use this class to keep track of almost anything you want. Finally, there are some built-in collection classes that make many Visual Basic operations much easier. In this section, I’ll show you how to use the generic Collection class. Later in the chapter, we’ll look into Visual Basic’s built-in classes. What exactly is a Collection? Let me quote from the Visual Basic Help system: “A collection object is an ordered set of items that can be referred to as a unit.” Think of a collection as an expandable set of numbered cubbyholes. You can put just about anything you like in the cubbyholes, and the collection helps you keep track of them and access them. The power of collections is further enhanced in that the items in a collection do not all have to be the same data type (although they often will be). You can do five basic functions with a collection: • Determine how many items are in the collection with the Count property. • Add a new item with the Add method. • Remove an existing item with the Remove method. • Retrieve an item with the Item method. • Loop through